package net.jalbum.filters.arty.effects;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.util.Map;

/**
 *
 * @author Sarah Schölzel 
 */
public class PinkFilter extends ArtySupport {

    public PinkFilter() {
    }

    @Override
    public String getName() {
        return "Pink";
    }

    @Override
    public String getDescription() {
        return "effect like the Early Bird filter in Instagram";
    }

    @Override
    public BufferedImage filter(BufferedImage bi, Map map) {
        return filter(bi);
    }

    @Override
    public BufferedImage filter(BufferedImage bi) {
        bi = super.filter(bi);

        //Brightness and Contrast
        bi = applyBrightnessAndContrast(bi, -5, 10);

        //Saturation
        bi = applySaturation(bi, -25);
        bi = applySaturation(bi, -10);

        //Border
        BufferedImage dstImg = adjustBorder(bi);

        //new ColorLayer
        BufferedImage tmpImg = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
        Graphics2D gt = tmpImg.createGraphics();
        gt.setColor(new Color(250, 245, 215));
        gt.fill(new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));

        //Blending mode: multiply, 100%
        Graphics2D gdst = dstImg.createGraphics();
        gdst.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.MULTIPLY, 1.0f));
        gdst.drawImage(tmpImg, 0, 0, bi.getWidth(), bi.getHeight(), null);

        //Copy of ColorLayer
        BufferedImage tmp2 = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
        Graphics2D g2 = tmp2.createGraphics();
        g2.setColor(new Color(250, 245, 215));
        g2.fill(new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));

        //Blending mode: Overlay, 40%
        gdst.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.OVERLAY, 0.3f));
        gdst.drawImage(tmp2, 0, 0, bi.getWidth(), bi.getHeight(), null);

        return dstImg;
    }
}
